home *** CD-ROM | disk | FTP | other *** search
- /* WARNING: THIS EXAMPLE IS QUICK & DIRTY!!! Its only purpose is to */
- /* demonstrate how certain MB_lib functions are used and how they work. */
- /* While the code is a functional program, no attempt has been made to */
- /* clean up the code or to streamline it, and I've economized a bit on */
- /* error checking since I've made this in a hurry. However, if you're */
- /* able to use MB_lib, odds are that you also know how to write neat code. */
-
- /* Scan mail to a certain user, first forward, then reverse */
-
- #include <string.h>
- #include <stdlib.h>
- #include <iostream.h>
-
- #include "msgbase.hpp"
-
-
- void main (void)
-
- {
- int nmsgs;
- long recnr;
- MSGTOIDX_RECORD to;
- MsgBase Message ("C:\\MSGBASE");
-
-
- if (!Message.ErrorType)
- {
- // cout << "User name? ";
- // cin.getline (to, sizeof(to) - 1, '\n');
- strcpy (to, "Frank van.Wensveen");
-
- cout << "\n\nListing forward...\n";
-
- recnr = Message.FirstTo (&to);
- if (Message.ErrorType)
- {
- cerr << "Error: " << Message.ErrorType << ", "
- << Message.ErrorString << ".\n";
- }
-
- nmsgs = 0;
- while (recnr != -1)
- {
- nmsgs++;
- Message.ReadHdr (recnr); /* Ignore errors for the moment */
- if (errortype)
- {
- cerr << "Error: " << Message.ErrorType << ", "
- << Message.ErrorString << ".\n";
- break;
- }
- cout << "Board: " << Message.Board()
- << " Message: " << Message.MsgNum()
- << "\nBy: " << Message.From()
- << "\nRe: " << Message.Subject() << "\n\n";
- recnr = Message.NextTo ();
- if (errortype)
- {
- cerr << "Error: " << Message.ErrorType << ", "
- << Message.ErrorString << ".\n";
- break;
- }
- }
- cout << nmsgs << " messages found\n";
-
- cout << "Listing revers...\n";
- recnr = Message.LastTo (&to);
- if (Message.ErrorType)
- {
- cerr << "Error: " << Message.ErrorType << ", "
- << Message.ErrorString << ".\n";
- }
-
- nmsgs = 0;
- while (recnr != -1)
- {
- nmsgs++;
- Message.ReadHdr (recnr); /* Ignore errors for the moment */
- if (Message.ErrorType)
- {
- cerr << "Error: " << Message.ErrorType << ", "
- << Message.ErrorString << ".\n";
- break;
- }
- cout << "Board: " << Message.Board()
- << " Message: " << Message.MsgNum()
- << "\nBy: " << Message.From()
- << "\nRe: " << Message.Subject() << "\n\n";
- recnr = Message.PrevTo ();
- if (Message.ErrorType)
- {
- cerr << "Error: " << Message.ErrorType << ", "
- << Message.ErrorString << ".\n";
- break;
- }
- }
- cout << nmsgs << " messages found\n";
- }
-
- cout << "Done.\n";
- exit (1);
- }
-